package org.singledog.dogmail.common.excetption;

import lombok.Getter;
import org.singledog.dogmail.common.entity.BaseResponse;

@Getter
public class BusinessException extends RuntimeException implements BaseResponse{

    private Integer code;


    private BusinessException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    private BusinessException(BaseResponse baseResponse) {
        super(baseResponse.getMessage());
        this.code = baseResponse.getCode();
    }

    public static BusinessException build(Integer code, String message) {
        return new BusinessException(code, message);
    }

    public static BusinessException build(BaseResponse baseResponse) {
        return new BusinessException(baseResponse);
    }
}
